package com.echo.register.commons.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.Cookie;

public class CookieHolder {

    private static Logger logger = LoggerFactory.getLogger(CookieHolder.class);

    private final static ThreadLocal<Cookie> cookieHolder = new ThreadLocal<>();

    public static void add(Cookie cookie){
        if(cookie == null){
            logger.info("cookieHolder add cookie is null");
        }else {
            logger.info("cookieHolder add cookie is {}", cookie.getValue());
            cookieHolder.set(cookie);
        }
    }

    public static Cookie get(){
        return cookieHolder.get();
    }

    public static void remove(){
        cookieHolder.remove();
    }
}
